home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / DB_KH.ZIP / DB.DOC < prev    next >
Encoding:
Text File  |  1990-01-28  |  48.9 KB  |  1,507 lines

  1.  
  2.  
  3.  
  4.  
  5.                          
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.         ######    ######        ######    #######  #####
  16.  
  17.         #     # #     #     #     # #     # #     #
  18.  
  19.         #     # #     #     #     # #     # #
  20.  
  21.         #     # ######        #     # #     # #
  22.  
  23.         #     # #     #   ###    #     # #     # #
  24.  
  25.         #     # #     #   ###    #     # #     # #     #
  26.  
  27.         ######    ######      ###    ######    #######  #####
  28.  
  29.             
  30.  
  31.  
  32.  
  33.             #     #    #         #####
  34.  
  35.             #     #   ##        #     #
  36.  
  37.             #     #  # #              #
  38.  
  39.             #     #    #         #####
  40.  
  41.              #   #       #      ###          #
  42.  
  43.               # #       #      ###    #     #
  44.  
  45.                #     #####      ###     #####
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.               (c) 1987, 1990
  54.  
  55.  
  56.  
  57.                               Ken Harris
  58.  
  59.                   901 E. Hampton
  60.  
  61.                   Milwaukee, WI  53217
  62.  
  63.                   (414) 962-1961
  64.  
  65.                   harris@cvax.cs.uwm.edu
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. /****************************************************************************/
  100.  
  101. /*                                                                          */
  102.  
  103. /*      This software is made available on an AS-IS basis. Unrestricted     */
  104.  
  105. /*      use is granted provided that the copyright notice remains intact.   */
  106.  
  107. /*    The author makes no warranties expressed or implied; however, any   */
  108.  
  109. /*    feedback is welcome.                            */
  110.  
  111. /*                                                                          */
  112.  
  113. /****************************************************************************/
  114.  
  115.          
  116.  
  117.  
  118.  
  119.     V1.2 Release Notes:
  120.  
  121.     ---- ------- -----
  122.  
  123.  
  124.  
  125.     (1)  The DB_READ_LAST and DB_READ_PREV routines have been added
  126.  
  127.          to allow backwards traversal. The routines work for all three
  128.  
  129.          file types. DB_DELETE should not be used with these routines.
  130.  
  131.          The delete routine sets the current record pointer so that a
  132.  
  133.          subsequent DB_READ_NEXT will work correctly. A DB_READ_PREV
  134.  
  135.          loop with DB_DELETES will result in skipped records.
  136.  
  137.                                   
  138.  
  139.  
  140.  
  141.     (2)  A number of bugs in the file create routine have been fixed.
  142.  
  143.  
  144.  
  145.  
  146.  
  147.     (3)  A file corruption bug in the Index delete routine has been
  148.  
  149.          fixed.
  150.  
  151.  
  152.  
  153.  
  154.  
  155.     (4)  The distribution has been divided into three separately
  156.  
  157.          compiled files. 
  158.  
  159.  
  160.  
  161.  
  162.  
  163.     (5)  Large memory model now works correctly.
  164.  
  165.  
  166.  
  167.  
  168.  
  169.     (6)  A lot of "warning" type problems have been cleaned up.
  170.  
  171.  
  172.  
  173.     (7)  Just before releasing V1.2 Microsoft C V5.0 rolled in
  174.  
  175.          the door so I was able to fix a couple of problems. 
  176.  
  177.          There are still some warning messages while compiling
  178.  
  179.          db_main.c. This is the result of ",..." type declarations
  180.  
  181.          used to prevent type checking of the user_data argument.
  182.  
  183.          User programs don't have to type cast user_data to char*
  184.  
  185.          to avoid warnings.
  186.  
  187.  
  188.  
  189.     (8)  I have avoided the temptation of using too many of the
  190.  
  191.          ANSI C extensions for those folks with old compilers.
  192.  
  193.          Also I'd rather not fill the code with a zillion IFDEF's.
  194.  
  195.          
  196.  
  197.  
  198.  
  199.  
  200.  
  201.     V1.3 Release Notes:
  202.  
  203.     ---- ------- -----
  204.  
  205.  
  206.  
  207.     (1)  A variable type file has been added. It is a sequential file
  208.  
  209.          with variable length records.
  210.  
  211.  
  212.  
  213.     (2)  A simple object dictionary manager has been added. It works
  214.  
  215.          well for a small data base of non-homogeneous objects, for
  216.  
  217.          example setup data records.
  218.  
  219.  
  220.  
  221.     (3)  The file descriptor pointer is now called DATA_FILE instead of
  222.  
  223.          DATA_SET. DATA_SET is still defined so that V1.2 programs
  224.  
  225.          will compile.
  226.  
  227.  
  228.  
  229.     (4)  The db_create routine arguments have changed. An option
  230.  
  231.          string is now passed instead of a df_file_hdr pointer. This
  232.  
  233.          is much cleaner. It will require changing any V1.2 programs
  234.  
  235.          before they will work.
  236.  
  237.  
  238.  
  239.     (5)  A number of routines now take an optional final record size
  240.  
  241.          argument. This is only required for VAR type files. It may
  242.  
  243.          be ignored for other file types.
  244.  
  245.  
  246.  
  247.     (6)  Existing V1.2 data files should work with V1.3 routines.
  248.  
  249.          The first time the file is openned and updated the file
  250.  
  251.          version will be changed from 1.2 to 1.3.
  252.  
  253.  
  254.  
  255.     (7)  Compiler conditionals have been added to DB_MAIN.C to
  256.  
  257.          bracket references to file-type specific routines. This
  258.  
  259.          makes it possible to build a library with support for
  260.  
  261.          only file types you need. The lexical variables are
  262.  
  263.          SEQ, RAN, IDX, VAR and ALL. So if SEQ is defined, then
  264.  
  265.          sequential file support is included, etc. Note that
  266.  
  267.          DB_DICT uses VAR files. If an attempt is made to access
  268.  
  269.          an unsupported file-type an error will occur. 
  270.  
  271.  
  272.  
  273.          Only the references to routines are IFDEFed. If you build
  274.  
  275.          a subset library you will probably get warning messages
  276.  
  277.          about some unreferenced variables. It's ok.
  278.  
  279.  
  280.  
  281.     (8)  Compiler conditionals are used to bracket compiler specific
  282.  
  283.          code. The current conditionals are:
  284.  
  285.         MSC   - Microsoft C
  286.  
  287.         TURBO - Turbo C
  288.  
  289.         SYSV  - Unix Sys V 
  290.  
  291.  
  292.  
  293.          In addition ANSI can be defined to use ANSI style function
  294.  
  295.          prototypes. You will probably want to edit #defines for
  296.  
  297.          your compiler and ANSI at the beginning of db.h.
  298.  
  299.  
  300.  
  301.     (9)  A header file, dblib.h, has been added for building the
  302.  
  303.          library. It is not needed for application programs. It
  304.  
  305.          contains compiler specific includes and defines.
  306.  
  307.  
  308.  
  309.     V1.3 Release Notes (cont):
  310.  
  311.     ---- ------- -----
  312.  
  313.  
  314.  
  315.     (10) The header file contains references to DB_LINK routines.
  316.  
  317.          These are routines for linking records between files.
  318.  
  319.          They have not been included in the distribution.
  320.  
  321.  
  322.  
  323.     (11) The routines memedt and stredt are no longer used by the
  324.  
  325.          db routines and have been removed from the distribution.
  326.  
  327.  
  328.  
  329.     (12) The *test.c files are intended to provide a minimal test
  330.  
  331.          of the routines. If the the tests run to compeletion
  332.  
  333.          without crashing or generating a DB-ERROR then there is
  334.  
  335.          a good chance that you're in business. The tests are
  336.  
  337.          not necessarily good examples of using the routines.
  338.  
  339.  
  340.  
  341.     (13) The routines have been built and tested on several
  342.  
  343.          different machines. Most of the development for v1.3
  344.  
  345.          was done under Ultrix on a VAXstation-2000 with gcc.
  346.  
  347.          It has also been sucessfully built using MSC 5.1 and
  348.  
  349.          Turbo C 2.0 under MSDOS and cc under Unix on a 3B1. 
  350.  
  351.  
  352.  
  353.          If your compiler is not one of these you should still 
  354.  
  355.          be able to build the routines without too much trouble.
  356.  
  357.          Search through the code for MSC 's and add an
  358.  
  359.          appropriate case for your compiler. 
  360.  
  361.  
  362.  
  363.     (14) Note that although this code works fine on Unix systems,
  364.  
  365.          it is still single user. There is no support for record
  366.  
  367.          locking or file sharing. 
  368.  
  369.  
  370.  
  371.         +----------+            -------------------               +----------+
  372.  
  373.         | db_Intro |            - DB Introduction -               | db_Intro |
  374.  
  375.         +----------+            -------------------               +----------+
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.         o Description
  384.  
  385.  
  386.  
  387.                     This document describes the DB package for maintaining
  388.  
  389.             data files. The package consists of a library of file handling
  390.  
  391.             routines which may be linked with user programs.
  392.  
  393.  
  394.  
  395.             The following four file organizations are supported:
  396.  
  397.  
  398.  
  399.                (1) Sequential - This file is a sequential stream of fixed
  400.  
  401.                 length records.
  402.  
  403.  
  404.  
  405.                (2) Index      - Data records are stored in an ISAM type
  406.  
  407.                                 organization.
  408.  
  409.  
  410.  
  411.                (3) Random     - Data records are stored using a hashed method.
  412.  
  413.  
  414.  
  415.            (4) Variable   - A sequential stream of variable length
  416.  
  417.                 records.
  418.  
  419.                      
  420.  
  421.  
  422.  
  423.             The following operations are supported:
  424.  
  425.  
  426.  
  427.             db_read_last         -  Read Last Record 
  428.  
  429.             db_read_prev         -  Read Prev Record
  430.  
  431.                 db_add               -  Add a New Record a File 
  432.  
  433.                 db_close             -  Close an Open Data Set
  434.  
  435.                 db_create            -  Create a New Data Set
  436.  
  437.                 db_delete            -  Delete the Current Record
  438.  
  439.                 db_dict_add          -  Dict Add Object
  440.  
  441.                 db_dict_close        -  Dict Close 
  442.  
  443.                 db_dict_delete       -  Dict Object Delete 
  444.  
  445.                 db_dict_delete_all   -  Dict Delete All 
  446.  
  447.                 db_dict_dump         -  Dict Dump to a File
  448.  
  449.                 db_dict_find         -  Dict Find Object
  450.  
  451.                 db_dict_find_all     -  Dict Find All 
  452.  
  453.                 db_dict_init         -  Dict Initialize
  454.  
  455.                 db_dict_load         -  Dict Load From File
  456.  
  457.                 db_error_msg         -  Get Error Message Text
  458.  
  459.                 db_find              -  Find a Record by Key   
  460.  
  461.                 db_get_rec_no        -  Get Relative Record # 
  462.  
  463.                 db_open              -  Open an Existing Data Set
  464.  
  465.                 db_read_atr          -  Read Attribute Data  
  466.  
  467.                 db_read_direct       -  Read by Record #   
  468.  
  469.                 db_read_first        -  Read First Record 
  470.  
  471.                 db_read_next         -  Read Next Record 
  472.  
  473.                 db_reorg             -  Reorganize Free Space
  474.  
  475.                 db_update            -  Update the Current Record
  476.  
  477.                 db_update_atr        -  Update Attribute Data 
  478.  
  479.  
  480.  
  481.         +------+           -------------------------------           +------+
  482.  
  483.         | db.h |           - Data Set Structures Defines -           | db.h |
  484.  
  485.         +------+           -------------------------------           +------+
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.         o Summary
  494.  
  495.  
  496.  
  497.                 #include <db.h>
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.         o Description
  506.  
  507.  
  508.  
  509.                 This header file contains the definitions for the global
  510.  
  511.                 structures that are used by all of the DB routines. It 
  512.  
  513.                 should be included in any program that calls DB routines.
  514.  
  515.                 The user program needs only to declare DATA_FILE descriptor
  516.  
  517.                 pointers for the data files that are to be used. The
  518.  
  519.                 DATA_FILE descriptor pointer is used to refer to the data
  520.  
  521.                 files.
  522.  
  523.  
  524.  
  525.  
  526.  
  527.                 A global variable db_error is used to return a status
  528.  
  529.                 value after any call to a DB routine. The header file
  530.  
  531.                 includes constant declarations for db_error values. 
  532.  
  533.                 The user program can check for specific conditions
  534.  
  535.                 such as DB_END_OF_FILE. A function call db_error_msg()
  536.  
  537.                 can be used to get the error message text corresponding
  538.  
  539.                 to the value of db_error.
  540.  
  541.  
  542.  
  543.         +--------+     ------------------------------------         +--------+
  544.  
  545.         | db_add |     -  Add a New Record to a Data Set  -         | db_add |
  546.  
  547.         +--------+     ------------------------------------         +--------+
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.         o Summary
  556.  
  557.  
  558.  
  559.                 #include <db.h>
  560.  
  561.  
  562.  
  563.                 ulong db_add(df, user_data, data_size)
  564.  
  565.                   DATA_FILE  df;
  566.  
  567.                   void     *user_data;
  568.  
  569.           int       data_size;
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.         o Description
  578.  
  579.  
  580.  
  581.                 This function is used to add a new record to a data file.
  582.  
  583.                 The data file is specified by the input df and user_data
  584.  
  585.                 points to the data record to be added.
  586.  
  587.  
  588.  
  589.                 For Indexed and Random data files, the first field of the
  590.  
  591.                 data record (user_data) must contain the record key value.
  592.  
  593.  
  594.  
  595.         For Variable data files, the data_size field contains the
  596.  
  597.         size of the variable length user_data record. The field
  598.  
  599.         is not used for the other file types.
  600.  
  601.  
  602.  
  603.                 The value of Current Record (used by db_read_next) is reset
  604.  
  605.                 to NONE by this operation.
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.         o Returns
  614.  
  615.  
  616.  
  617.                 The relative record number of the new record is returned.
  618.  
  619.                 If an error occurs a zero value is returned and the global
  620.  
  621.                 db_error contains the error number.
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.         +----------+         ----------------------------         +----------+
  630.  
  631.         | db_close |         -  Close an Open Data Set  -         | db_close |
  632.  
  633.         +----------+         ----------------------------         +----------+
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.         o Summary
  642.  
  643.  
  644.  
  645.                 #include <db.h>
  646.  
  647.  
  648.  
  649.                 DATA_FILE db_close(df)
  650.  
  651.                   DATA_FILE  df;
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.         o Description
  660.  
  661.  
  662.  
  663.                 This function terminates all processing for an open data file.
  664.  
  665.                 The associated file is closed and all dynamic storage is
  666.  
  667.                 released.
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.         o Returns
  676.  
  677.  
  678.  
  679.                 The completion status of the function is returned in the
  680.  
  681.         global db_error. The function itself returns a NULL pointer
  682.  
  683.         value.
  684.  
  685.  
  686.  
  687.         +-----------+         -------------------------         +-----------+
  688.  
  689.         | db_create |         - Create a New Data Set -         | db_create |
  690.  
  691.         +-----------+         -------------------------         +-----------+
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.         o Summary
  700.  
  701.  
  702.  
  703.                 #include <db.h>
  704.  
  705.  
  706.  
  707.                 DATA_FILE db_create(path, fname, options)
  708.  
  709.                   char *path, *fname, *options;
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.         o Description
  718.  
  719.  
  720.  
  721.                 This function is used to create a new data file. The inputs
  722.  
  723.                 are as follows:
  724.  
  725.  
  726.  
  727.                      path    -  Path name of data directory
  728.  
  729.                      fname   -  File name of new data file
  730.  
  731.                      options -  Create options string 
  732.  
  733.  
  734.  
  735.  
  736.  
  737.         The option string contains a list of create options
  738.  
  739.         seperated by commas. The following options are supported:
  740.  
  741.  
  742.  
  743.             SEQ         - Sequential file organization 
  744.  
  745.             RAN          - Random file organization
  746.  
  747.             IDX          - Index file organization
  748.  
  749.             VAR          - Variable file organization  
  750.  
  751.             BLK    = nnn - Size of block 
  752.  
  753.             REC    = nnn - Size of record
  754.  
  755.             BASE   = nnn - Size of Random file base area
  756.  
  757.                        (Should be a prime number)
  758.  
  759.             KEY    = nnn - Size of the record key
  760.  
  761.             ATR    = nnn - Size of Attribute block   
  762.  
  763.             DUPS         - Duplicate record keys allowed
  764.  
  765.             NODUPS       - Duplicate record keys NOT allowd
  766.  
  767.  
  768.  
  769.  
  770.  
  771.                 O P T I O N   T A B L E
  772.  
  773.                 ===========   =========
  774.  
  775.  
  776.  
  777.  
  778.  
  779.                 +===============================+
  780.  
  781.                 |   -- File Organizations --    |
  782.  
  783.         +===============+=======+=======+=======+=======+
  784.  
  785.         |  - Options -  | SEQ   | RAN   | IDX   | VAR   |
  786.  
  787.         +===============+=======+=======+=======+=======+
  788.  
  789.         | SEQ        | REQ    | -    | -    + -    |
  790.  
  791.         +---------------+-------+-------+-------+-------+
  792.  
  793.         | RAN        | -    | REQ    | -    + -    |
  794.  
  795.         +---------------+-------+-------+-------+-------+
  796.  
  797.         | IDX        | -    | -    | REQ    + -    |
  798.  
  799.         +---------------+-------+-------+-------+-------+
  800.  
  801.         | VAR        | -    | -    | -    + REQ    |
  802.  
  803.         +---------------+-------+-------+-------+-------+
  804.  
  805.         | BLK        | OPT    | OPT    | OPT    + OPT    |
  806.  
  807.         +---------------+-------+-------+-------+-------+
  808.  
  809.         | REC        | REQ    | REQ    | REQ    + REQ    |
  810.  
  811.         +---------------+-------+-------+-------+-------+
  812.  
  813.         | BASE        | -    | REQ    | -    + -    |
  814.  
  815.         +---------------+-------+-------+-------+-------+
  816.  
  817.         | KEY        | -    | REQ    | REQ    + -    |
  818.  
  819.         +---------------+-------+-------+-------+-------+
  820.  
  821.         | ATR        | OPT    | OPT    | OPT    + OPT    |
  822.  
  823.         +---------------+-------+-------+-------+-------+ 
  824.  
  825.         | DUPS         | -    | -    | OPT    + -    |
  826.  
  827.         +---------------+-------+-------+-------+-------+
  828.  
  829.         | NODUPS    | -    | -    | OPT    + -    |
  830.  
  831.         +===============+=======+=======+=======+=======+
  832.  
  833.           REQ = Required   OPT = Optional  - = Doesn't Apply
  834.  
  835.  
  836.  
  837.  
  838.  
  839.     o Examples:
  840.  
  841.  
  842.  
  843.         df = db_create("c:\\data", "test.dat", "SEQ, REC=32");
  844.  
  845.  
  846.  
  847.         df = db_create("", "test.dat", "RAN,REC=32,KEY=2,BASE=29");
  848.  
  849.  
  850.  
  851.         df = db_create("", "test.dat", "IDX, REC=50, KEY=5");
  852.  
  853.  
  854.  
  855.  
  856.  
  857.         o Returns
  858.  
  859.  
  860.  
  861.                 This function returns a pointer to the data file descriptor
  862.  
  863.                 block for the newly created data file. This value should be 
  864.  
  865.                 used for future references to the data file. The status of 
  866.  
  867.                 the data file is open.
  868.  
  869.  
  870.  
  871.                 The return status is available in the global db_error. If 
  872.  
  873.                 an error occurs the new data file is not created and a null
  874.  
  875.                 descriptor pointer is returned.
  876.  
  877.  
  878.  
  879.         +-----------+      -------------------------------      +-----------+
  880.  
  881.         | db_delete |      -  Delete the Current Record  -      | db_delete |
  882.  
  883.         +-----------+      -------------------------------      +-----------+
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.         o Summary
  892.  
  893.  
  894.  
  895.                 #include <db.h>
  896.  
  897.  
  898.  
  899.                 void db_delete(df)
  900.  
  901.                   DATA_FILE  df;
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.         o Description
  910.  
  911.  
  912.  
  913.                 This function is used to delete the Current Record from the
  914.  
  915.                 data file specified by df.
  916.  
  917.  
  918.  
  919.                 This function must be preceeded by some function that 
  920.  
  921.                 establishes the Current Record for the data file.
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.         o Returns
  930.  
  931.  
  932.  
  933.                 The completion status is returned in the global db_error. 
  934.  
  935.                 A non-zero value indicates an error. The Current Record
  936.  
  937.                 for the data file is reset to NONE.
  938.  
  939.  
  940.  
  941.         +---------+           -------------------------           +---------+
  942.  
  943.         | db_dict |           -  Dictionary Routines  -           | db_dict |
  944.  
  945.         +---------+           -------------------------           +---------+
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.         o Description
  954.  
  955.  
  956.  
  957.         The dictionary routines can be used to maintain a simple
  958.  
  959.         object dictionary. Objects are of arbitrary size and are
  960.  
  961.         referenced by name and type. A dictionary may be dumped
  962.  
  963.         to or loaded from a VAR file. If the DB_DICT routines are
  964.  
  965.         to be used, VAR file support must be included in the
  966.  
  967.         library.
  968.  
  969.  
  970.  
  971.         A dictionary is memory resident. It makes a good place
  972.  
  973.         to store a non-homogenous collection of objects (records).
  974.  
  975.         
  976.  
  977.  
  978.  
  979.         The following functions are supported:
  980.  
  981.  
  982.  
  983.                 db_dict_add          -  Dict Add Object
  984.  
  985.                 db_dict_close        -  Dict Close 
  986.  
  987.                 db_dict_delete       -  Dict Object Delete 
  988.  
  989.                 db_dict_delete_all   -  Dict Delete All 
  990.  
  991.                 db_dict_dump         -  Dict Dump to a File
  992.  
  993.                 db_dict_find         -  Dict Find Object
  994.  
  995.                 db_dict_find_all     -  Dict Find All 
  996.  
  997.                 db_dict_init         -  Dict Initialize
  998.  
  999.                 db_dict_load         -  Dict Load From File
  1000.  
  1001.  
  1002.  
  1003.         +--------------+        ---------------------        +--------------+
  1004.  
  1005.         | db_dict_init |        -  Dict Initialize  -        | db_dict_init |
  1006.  
  1007.         +--------------+        ---------------------        +--------------+
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.         o Summary
  1016.  
  1017.  
  1018.  
  1019.                 #include <db.h>
  1020.  
  1021.  
  1022.  
  1023.                 DICT db_dict_init() 
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.         o Description
  1032.  
  1033.  
  1034.  
  1035.         This function is used to create a new dictionary. It must
  1036.  
  1037.         be called before any other dictionary routines.
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.         o Returns
  1046.  
  1047.  
  1048.  
  1049.         A pointer to the new dictionary is returned. If an error
  1050.  
  1051.         occurs a NULL pointer is returned and db_error contains
  1052.  
  1053.         the error code.
  1054.  
  1055.  
  1056.  
  1057.         +---------------+          ----------------         +---------------+
  1058.  
  1059.         | db_dict_close |          -  Dict Close  -         | db_dict_close |
  1060.  
  1061.         +---------------+          ----------------         +---------------+
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.         o Summary
  1070.  
  1071.  
  1072.  
  1073.                 #include <db.h>
  1074.  
  1075.  
  1076.  
  1077.                 void db_dict_close(dict)
  1078.  
  1079.           DICT dict;
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.         o Description
  1088.  
  1089.  
  1090.  
  1091.                 This function is used to close up the dictionary dict.
  1092.  
  1093.         All allocated storage will be freed. The dict variable
  1094.  
  1095.         should be set to NULL after a close.
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.         o Returns
  1104.  
  1105.  
  1106.  
  1107.                 The completion status is returned in the global db_error. 
  1108.  
  1109.                 A non-zero value indicates an error.
  1110.  
  1111.  
  1112.  
  1113.         +-------------+         ---------------------         +-------------+
  1114.  
  1115.         | db_dict_add |         -  Dict Add Object  -         | db_dict_add |
  1116.  
  1117.         +-------------+         ---------------------         +-------------+
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.         o Summary
  1126.  
  1127.  
  1128.  
  1129.                 #include <db.h>
  1130.  
  1131.  
  1132.  
  1133.                 void *db_dict_add(dict, name, o_type, o_size, obj)
  1134.  
  1135.           DICT  dict;        /* Dictionary pointer        */
  1136.  
  1137.           char *name;          /* Name of the object        */
  1138.  
  1139.           int   o_type;        /* Object type            */
  1140.  
  1141.           int   o_size;        /* Object size            */
  1142.  
  1143.           void *obj;        /* Pointer to the object    */
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.         o Description
  1152.  
  1153.  
  1154.  
  1155.         This function is used to add a new object to a dictionary.
  1156.  
  1157.         The dictionary is specified by dict. Name is the lookup
  1158.  
  1159.         name for the object. The o_type is a user specified type 
  1160.  
  1161.         which can be used to group like objects together. The o_size
  1162.  
  1163.         is the size of the object in bytes. Obj is a pointer to
  1164.  
  1165.         the object. If sucessful, a new object is created in the
  1166.  
  1167.         specified dictionary and the contents of obj are copied
  1168.  
  1169.         to it. 
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.         o Returns
  1178.  
  1179.  
  1180.  
  1181.         A pointer to the new object is returned. If an error occurs,
  1182.  
  1183.         a NULL pointer is returned and db_error contains the error
  1184.  
  1185.         code.
  1186.  
  1187.  
  1188.  
  1189.         +----------------+    ------------------------     +----------------+
  1190.  
  1191.         | db_dict_delete |    -  Dict Object Delete  -     | db_dict_delete |
  1192.  
  1193.         +----------------+    ------------------------     +----------------+
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.         o Summary
  1202.  
  1203.  
  1204.  
  1205.                 #include <db.h>
  1206.  
  1207.  
  1208.  
  1209.                 void db_dict_delete(dict, name, o_type)
  1210.  
  1211.           DICT  dict;
  1212.  
  1213.           char *name;
  1214.  
  1215.           int   o_type;
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.         o Description
  1224.  
  1225.  
  1226.  
  1227.         This function is used to delete an object from the
  1228.  
  1229.         dictionary dict. Name is the name of the object to
  1230.  
  1231.         delete. O_type is the type of the object to delete.
  1232.  
  1233.         There may be mutiple objects with the same name but
  1234.  
  1235.         different types. If o_type is 0, then all types will
  1236.  
  1237.         be deleted. If sucessful, the matching object(s) is
  1238.  
  1239.         removed.
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.         o Returns
  1248.  
  1249.  
  1250.  
  1251.                 The completion status is returned in the global db_error. 
  1252.  
  1253.                 A non-zero value indicates an error. 
  1254.  
  1255.  
  1256.  
  1257.         +--------------------+     ---------------     +--------------------+
  1258.  
  1259.         | db_dict_delete_all |     Dict Delete All     | db_dict_delete_all |
  1260.  
  1261.         +--------------------+     ---------------     +--------------------+
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.         o Summary
  1270.  
  1271.  
  1272.  
  1273.                 #include <db.h>
  1274.  
  1275.  
  1276.  
  1277.                 void db_dict_delete_all(dict, o_type)
  1278.  
  1279.                   DICT  dict;
  1280.  
  1281.           int   o_type;
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.         o Description
  1290.  
  1291.  
  1292.  
  1293.                 This function is used to delete all objects of type o_type
  1294.  
  1295.         from the dictionary dict. If o_type is 0 then all objects
  1296.  
  1297.         will be removed.
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.         o Returns
  1308.  
  1309.  
  1310.  
  1311.                 The completion status is returned in the global db_error. 
  1312.  
  1313.                 A non-zero value indicates an error.
  1314.  
  1315.  
  1316.  
  1317.         +--------------+      -------------------------      +--------------+
  1318.  
  1319.         | db_dict_dump |      -  Dict Dump to a File  -      | db_dict_dump |
  1320.  
  1321.         +--------------+      -------------------------      +--------------+
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.         o Summary
  1330.  
  1331.  
  1332.  
  1333.                 #include <db.h>
  1334.  
  1335.  
  1336.  
  1337.                 void db_dict_dump(dict, path, fname)
  1338.  
  1339.           DICT   dict;
  1340.  
  1341.           char  *path;
  1342.  
  1343.           char  *fname;
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.         o Description
  1352.  
  1353.  
  1354.  
  1355.                 This function is used to dump the objects in a dictionary
  1356.  
  1357.         dict to a file. The file is specified by path and fname.
  1358.  
  1359.         A new VAR file will be created.
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.         o Returns
  1368.  
  1369.  
  1370.  
  1371.                 The completion status is returned in the global db_error. 
  1372.  
  1373.                 A non-zero value indicates an error.
  1374.  
  1375.  
  1376.  
  1377.         +--------------+        ----------------------       +--------------+
  1378.  
  1379.         | db_dict_find |        -  Dict Find Object  -       | db_dict_find |
  1380.  
  1381.         +--------------+        ----------------------       +--------------+
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.         o Summary
  1390.  
  1391.  
  1392.  
  1393.                 #include <db.h>
  1394.  
  1395.  
  1396.  
  1397.                 void *db_dict_find(dict, name, o_type)
  1398.  
  1399.           DICT  dict;
  1400.  
  1401.           char *name;
  1402.  
  1403.           int   o_type;
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.         o Description
  1412.  
  1413.  
  1414.  
  1415.                 This function is used to lookup an object in dictionary
  1416.  
  1417.         dict. Name is the name of the object to look for and o_type
  1418.  
  1419.         is the type. If o_type is 0 then the first matching object
  1420.  
  1421.         of any type will be found.
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.         o Returns
  1430.  
  1431.  
  1432.  
  1433.         A pointer to the found object is returned. If no matching
  1434.  
  1435.         object is found, a NULL pointer is returned and an error
  1436.  
  1437.         code is placed in db_error.
  1438.  
  1439.  
  1440.  
  1441.         +------------------+     -------------------     +------------------+
  1442.  
  1443.         | db_dict_find_all |     -  Dict Find All  -     | db_dict_find_all |
  1444.  
  1445.         +------------------+     -------------------     +------------------+
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.         o Summary
  1454.  
  1455.  
  1456.  
  1457.                 #include <db.h>
  1458.  
  1459.  
  1460.  
  1461.                 int db_dict_find_all(dict, o_type, nlist, olist)
  1462.  
  1463.                   DICT    dict;        /* Dictionary        */
  1464.  
  1465.           int     o_type;    /* Object type        */
  1466.  
  1467.           char ***nlist;    /* List of object names    */
  1468.  
  1469.           void ***olist;    /* List of object ptrs    */
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.         o Description
  1478.  
  1479.  
  1480.  
  1481.         This function is used to retrieve all the objects of type
  1482.  
  1483.         o_type from dictionary dict. If o_type is 0, then all
  1484.  
  1485.         types will be retrieved. The function allocates space and
  1486.  
  1487.         creates a list of pointers to the object names and a list
  1488.  
  1489.         of pointers to the objects themselves. Nlist and olist
  1490.  
  1491.         will be updated to point to the above two lists resp.
  1492.  
  1493.         The two lists should be freed when done with them.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.     o Example
  1502.  
  1503.  
  1504.  
  1505.         DICT  dict;
  1506.  
  1507.         char *names[], *objs[];
  1508.  
  1509.         int   i, cnt;
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.         cnt = db_find_all(dict, 1, &names, &objs);
  1516.  
  1517.         for (i=0; i<cnt; i++)
  1518.  
  1519.             printf("name[%d]=%s\n", names[i]);
  1520.  
  1521.  
  1522.  
  1523.         free(name);
  1524.  
  1525.         free(objs);
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.         o Returns
  1532.  
  1533.  
  1534.  
  1535.         A count of the number of objects found is returned. The
  1536.  
  1537.         two pointers nlist and olist are updated to point to the
  1538.  
  1539.         list of names and objects resp. If an error occurs, 0
  1540.  
  1541.         is returned, nlist and olist are set to NULL and an error
  1542.  
  1543.         code is place in db_error.
  1544.  
  1545.  
  1546.  
  1547.         +--------------+       ------------------------      +--------------+
  1548.  
  1549.         | db_dict_load |       -  Dict Load From File -      | db_dict_load |
  1550.  
  1551.         +--------------+       ------------------------      +--------------+
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.         o Summary
  1560.  
  1561.  
  1562.  
  1563.                 #include <db.h>
  1564.  
  1565.  
  1566.  
  1567.                 void db_dict_load(dict, path, fname)
  1568.  
  1569.                   DICT  dict;
  1570.  
  1571.           char *path;
  1572.  
  1573.           char *fname;
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.         o Description
  1582.  
  1583.  
  1584.  
  1585.                 This function is used to load a dictionary dict with
  1586.  
  1587.         objects from a file. The file is specified by path and
  1588.  
  1589.         fname. The dictionary must already be initialized. This
  1590.  
  1591.         allows multiple loads to a single dictionary. The file
  1592.  
  1593.         fname must be an existing VAR type file.
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.         o Returns
  1602.  
  1603.  
  1604.  
  1605.                 The completion status is returned in the global db_error. 
  1606.  
  1607.                 A non-zero value indicates an error.
  1608.  
  1609.  
  1610.  
  1611.         +----------+          -------------------------          +----------+
  1612.  
  1613.         | db_error |          -  Global Error Status  -          | db_error |
  1614.  
  1615.         +----------+          -------------------------          +----------+
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.         o Summary
  1624.  
  1625.  
  1626.  
  1627.                 extern int db_error;
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.         o Description
  1636.  
  1637.  
  1638.  
  1639.                 This global variable contains the completion status of
  1640.  
  1641.                 the most recent db_xxxx call. The following values and
  1642.  
  1643.                 associated constants are defined for V1.3:
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.             DB_FILE_NOT_FOUND      1
  1650.  
  1651.             DB_READ_ERROR          2
  1652.  
  1653.             DB_END_OF_FILE         3
  1654.  
  1655.             DB_WRITE_ERROR         4
  1656.  
  1657.             DB_FILE_NOT_CREATED    5
  1658.  
  1659.             DB_FILE_NOT_OPEN       6
  1660.  
  1661.             DB_INVALID_BLOCK       7
  1662.  
  1663.             DB_BUFFER_ERROR        8
  1664.  
  1665.             DB_NO_CURRENT_REC      9
  1666.  
  1667.             DB_DELETED_REC        10
  1668.  
  1669.             DB_INVALID_FREE       11
  1670.  
  1671.             DB_INVALID_BLK_SIZE   12
  1672.  
  1673.             DB_INVALID_INDEX      13
  1674.  
  1675.             DB_REC_NOT_FOUND      14
  1676.  
  1677.             DB_DUP_NOT_ALLOWED    15
  1678.  
  1679.             DB_INVALID_REQUEST    16
  1680.  
  1681.             DB_INVALID_RANDOM     17
  1682.  
  1683.             DB_INVALID_FHDR       18
  1684.  
  1685.             DB_VERSION_ERROR      19
  1686.  
  1687.             DB_INVALID_LINK       20
  1688.  
  1689.             DB_LINK_ERROR         21
  1690.  
  1691.             DB_FTYPE_ERROR        22
  1692.  
  1693.             DB_INVALID_OPTION     23
  1694.  
  1695.             DB_ALLOC_ERROR        24
  1696.  
  1697.             DB_VAR_SIZE_ERROR     25
  1698.  
  1699.             DB_VAR_CSUM_ERROR     26
  1700.  
  1701.             DB_UNSUPP_FEATURE     27
  1702.  
  1703.             DB_INVALID_DICT       28
  1704.  
  1705.             DB_INVALID_NAME       29
  1706.  
  1707.             DB_INVALID_ERROR      30
  1708.  
  1709.  
  1710.  
  1711.         +--------------+     ----------------------------    +--------------+
  1712.  
  1713.         | db_error_msg |     -  Get Error Message Text  -    | db_error_msg |
  1714.  
  1715.         +--------------+     ----------------------------    +--------------+
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.         o Summary
  1724.  
  1725.  
  1726.  
  1727.                 #include <db.h>
  1728.  
  1729.  
  1730.  
  1731.                 char *db_error_msg(error)
  1732.  
  1733.                   int   error;
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.         o Description
  1742.  
  1743.  
  1744.  
  1745.                 This function is used to get an error message corresponding
  1746.  
  1747.                 to the error number returned in db_error.
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.         o Returns
  1756.  
  1757.  
  1758.  
  1759.                 A pointer to the error message is returned.
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.         +---------+          --------------------------           +---------+
  1766.  
  1767.         | db_find |          -  Find a Record by Key  -           | db_find |
  1768.  
  1769.         +---------+          --------------------------           +---------+
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.         o Summary
  1778.  
  1779.  
  1780.  
  1781.                 #include <db.h>
  1782.  
  1783.  
  1784.  
  1785.                 void db_find(df, user_data, key, key_size)
  1786.  
  1787.                   DATA_FILE  df;
  1788.  
  1789.                   void     *user_data;                   
  1790.  
  1791.                   char     *key;
  1792.  
  1793.                   int       key_size;
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.         o Description
  1802.  
  1803.  
  1804.  
  1805.                 This function is used to find a record by key value. The
  1806.  
  1807.                 following are inputs:
  1808.  
  1809.  
  1810.  
  1811.                      df         -  specifies the data file
  1812.  
  1813.                      user_data  -  pointer to the destination buffer
  1814.  
  1815.                      key        -  pointer to key value
  1816.  
  1817.                      key_size   -  length of the key field
  1818.  
  1819.  
  1820.  
  1821.                 The key_length field allows for matching less than the
  1822.  
  1823.                 entire record key in an Index data file. A key_size of zero
  1824.  
  1825.                 defaults to entire key length. For a Random data file, the
  1826.  
  1827.                 key_length field is ignored.
  1828.  
  1829.  
  1830.  
  1831.                 This function is not valid for Sequential ior variable data 
  1832.  
  1833.         files.
  1834.  
  1835.                 
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.         o Returns
  1842.  
  1843.  
  1844.  
  1845.                 The data record is read into the buffer pointed to by
  1846.  
  1847.                 user_data. The read record becomes the Current Record
  1848.  
  1849.                 for this data file. The completion status is returned 
  1850.  
  1851.                 in the global db_error. A non-zero value indicates an 
  1852.  
  1853.                 error.
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.         +---------------+    ---------------------------    +---------------+
  1862.  
  1863.         | db_get_rec_no |    -  Get Relative Record #  -    | db_get_rec_no |
  1864.  
  1865.         +---------------+    ---------------------------    +---------------+
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.         o Summary
  1874.  
  1875.  
  1876.  
  1877.                 #include <db.h>
  1878.  
  1879.  
  1880.  
  1881.                 ulong db_get_rec_no(df)
  1882.  
  1883.                   DATA_FILE  df;
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.         o Description
  1892.  
  1893.  
  1894.  
  1895.                 This function returns the Relative Record Number for the
  1896.  
  1897.                 Current Record in the data file specified by df. The
  1898.  
  1899.                 Relative  Record Number for records in sequential data
  1900.  
  1901.                 files is fixed; however, for records in Index, Random
  1902.  
  1903.         and Variable data files the value may be changed due to 
  1904.  
  1905.         reorganizations that occur when adds and deletes take 
  1906.  
  1907.         place.
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.         o Returns
  1916.  
  1917.  
  1918.  
  1919.                 The value of the relative record number is returned.
  1920.  
  1921.         For Variable files the rrn is the lseek offsest of the
  1922.  
  1923.         record. For the other file organizations, the rrn is
  1924.  
  1925.         the actual record number from the beginning of the file.
  1926.  
  1927.  
  1928.  
  1929.                 If there is an error, a NULL value is returned and the
  1930.  
  1931.                 global db_error contains the error code.
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.         +---------+        -------------------------------        +---------+
  1938.  
  1939.         | db_open |        -  Open an Existing Data Set  -        | db_open |
  1940.  
  1941.         +---------+        -------------------------------        +---------+
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.         o Summary
  1950.  
  1951.  
  1952.  
  1953.                 #include <db.h>
  1954.  
  1955.  
  1956.  
  1957.                 DATA_FILE db_open(path, fname)
  1958.  
  1959.                   char *path, *fname;
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.         o Description
  1968.  
  1969.  
  1970.  
  1971.                 This function is used to open an existing data file. The inputs
  1972.  
  1973.                 are as follows:
  1974.  
  1975.  
  1976.  
  1977.                      path   -  Path name of data directory
  1978.  
  1979.                      fname  -  File name of the data fileo
  1980.  
  1981.         
  1982.  
  1983.         The path argument can also be treated as a string of 
  1984.  
  1985.         defaults.
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.         o Returns
  1994.  
  1995.  
  1996.  
  1997.                 This function returns a pointer to the data file descriptor
  1998.  
  1999.                 block for the data file. This value should be used for future 
  2000.  
  2001.                 references to the data file.
  2002.  
  2003.  
  2004.  
  2005.                 If an error occurs a NULL value is returned and the global
  2006.  
  2007.                 db_error contains the error number.
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.         +-------------+       -------------------------       +-------------+
  2018.  
  2019.         | db_read_atr |       -  Read Attribute Data  -       | db_read_atr |
  2020.  
  2021.         +-------------+       -------------------------       +-------------+
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.         o Summary
  2030.  
  2031.  
  2032.  
  2033.                 #include <db.h>
  2034.  
  2035.  
  2036.  
  2037.                 void db_read_atr(df, user_data)
  2038.  
  2039.                   DATA_FILE  df;                 
  2040.  
  2041.                   void      *user_data;
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.         o Description
  2050.  
  2051.  
  2052.  
  2053.                 This function is used to read the attribute record for a
  2054.  
  2055.                 data file. The data file is specified by df and user_data
  2056.  
  2057.                 points to the destination buffer.
  2058.  
  2059.  
  2060.  
  2061.                 The attribute data is a single user record that may be 
  2062.  
  2063.         used to store some global data for the data file.
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.         o Returns
  2074.  
  2075.  
  2076.  
  2077.                 The attribute record is read into the buffer pointed to by
  2078.  
  2079.                 user_data. The completion status is returned in the global 
  2080.  
  2081.                 db_error. A non-zero value indicates an error.
  2082.  
  2083.  
  2084.  
  2085.         +----------------+     -----------------------     +----------------+
  2086.  
  2087.         | db_read_direct |     -  Read by Record #   -     | db_read_direct |
  2088.  
  2089.         +----------------+     -----------------------     +----------------+
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.         o Summary
  2098.  
  2099.  
  2100.  
  2101.                 #include <db.h>
  2102.  
  2103.  
  2104.  
  2105.                 void db_read_direct(df, rec_no, user_data, data_size)
  2106.  
  2107.                   DATA_FILE  df;                 
  2108.  
  2109.                   ulong     rec_no;
  2110.  
  2111.                   void     *user_data;
  2112.  
  2113.           int      *data_size;
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.         o Description
  2122.  
  2123.  
  2124.  
  2125.                 This function is used to read a record directly by using its
  2126.  
  2127.                 Relative Record Number. The data file is specified by df,
  2128.  
  2129.                 the Relative Record Number is rec_no and user_data points
  2130.  
  2131.                 to the destination buffer.
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.         o Returns
  2140.  
  2141.  
  2142.  
  2143.                 The data record is read into the buffer pointed to by
  2144.  
  2145.                 user_data. If the file type is Variable, the length of
  2146.  
  2147.         the record read is placed in data_size. The read record 
  2148.  
  2149.         becomes the Current Record for this data file. The 
  2150.  
  2151.         completion status is returned in the global db_error. 
  2152.  
  2153.         A non-zero value indicates an error.
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.         +---------------+      -----------------------      +---------------+
  2160.  
  2161.         | db_read_first |      -  Read First Record  -      | db_read_first |
  2162.  
  2163.         +---------------+      -----------------------      +---------------+
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.         o Summary
  2172.  
  2173.  
  2174.  
  2175.                 #include <db.h>
  2176.  
  2177.  
  2178.  
  2179.                 void db_read_first(df, user_data, data_size)
  2180.  
  2181.                   DATA_FILE  df;
  2182.  
  2183.                   void     *user_data;
  2184.  
  2185.           int      *data_size;
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.         o Description
  2194.  
  2195.  
  2196.  
  2197.                 This function is used to read the first record from a 
  2198.  
  2199.         data file.  The data file is specified by df and user_data 
  2200.  
  2201.         points to the destination buffer for the record.
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.         o Returns
  2210.  
  2211.  
  2212.  
  2213.                 The data record is read into the buffer pointed to by
  2214.  
  2215.                 user_data. If the file type is Variable, the length of
  2216.  
  2217.         the record read is placed in data_size. The read record 
  2218.  
  2219.         becomes the Current Record for this data file. The 
  2220.  
  2221.         completion status is returned in the global db_error. 
  2222.  
  2223.         A non-zero value indicates an error.
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.     +--------------+       ----------------------         +--------------+
  2230.  
  2231.     | db_read_last |       -  Read Last Record  -         | db_read_last |
  2232.  
  2233.     +--------------+       ----------------------         +--------------+
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.         o Summary
  2242.  
  2243.  
  2244.  
  2245.                 #include <db.h>
  2246.  
  2247.  
  2248.  
  2249.         void db_read_last(df, user_data, data_size)
  2250.  
  2251.                   DATA_FILE  df;
  2252.  
  2253.                   void     *user_data;
  2254.  
  2255.           int      *data_size;
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.         o Description
  2264.  
  2265.  
  2266.  
  2267.         This function is used to read the last record from a 
  2268.  
  2269.         data file.  The data file is specified by df and user_data 
  2270.  
  2271.         points to the destination buffer for the record.
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.         o Returns
  2280.  
  2281.  
  2282.  
  2283.                 The data record is read into the buffer pointed to by
  2284.  
  2285.                 user_data. If the file type is Variable, the length of
  2286.  
  2287.         the record read is placed in data_size. The read record 
  2288.  
  2289.         becomes the Current Record for this data file. The 
  2290.  
  2291.         completion status is returned in the global db_error. 
  2292.  
  2293.         A non-zero value indicates an error.
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.         +--------------+       ----------------------        +--------------+
  2300.  
  2301.         | db_read_next |       -  Read Next Record  -        | db_read_next |
  2302.  
  2303.         +--------------+       ----------------------        +--------------+
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.         o Summary
  2312.  
  2313.  
  2314.  
  2315.                 #include <db.h>
  2316.  
  2317.  
  2318.  
  2319.                 void db_read_next(df, user_data, data_size)
  2320.  
  2321.                   DATA_FILE  df;
  2322.  
  2323.                   void     *user_data;
  2324.  
  2325.           int      *data_size;
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.         o Description
  2334.  
  2335.  
  2336.  
  2337.                 This function is used to read the next record from a 
  2338.  
  2339.         data file.  The data file is specified by df and user_data 
  2340.  
  2341.         points to the destination buffer for the record.
  2342.  
  2343.  
  2344.  
  2345.                 This function must be preceeded by some function that 
  2346.  
  2347.                 establishes the Current Record for the data file. For 
  2348.  
  2349.         example db_read_first followed by db_read_next until end 
  2350.  
  2351.         of file occurs. The value of Current Record is reset to 
  2352.  
  2353.         NONE by a db_add.
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.         o Returns
  2362.  
  2363.  
  2364.  
  2365.                 The data record is read into the buffer pointed to by
  2366.  
  2367.                 user_data. If the file type is Variable, the length of
  2368.  
  2369.         the record read is placed in data_size. The read record 
  2370.  
  2371.         becomes the Current Record for this data file. The 
  2372.  
  2373.         completion status is returned in the global db_error. 
  2374.  
  2375.         A non-zero value indicates an error.
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.         +--------------+       ----------------------        +--------------+
  2382.  
  2383.     | db_read_prev |       -  Read Prev Record  -         | db_read_prev |
  2384.  
  2385.         +--------------+       ----------------------        +--------------+
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.  
  2393.         o Summary
  2394.  
  2395.  
  2396.  
  2397.                 #include <db.h>
  2398.  
  2399.  
  2400.  
  2401.         void db_read_prev(df, user_data, data_size)
  2402.  
  2403.                   DATA_FILE  df;
  2404.  
  2405.                   void     *user_data;
  2406.  
  2407.           int      *data_size;
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.         o Description
  2416.  
  2417.  
  2418.  
  2419.         This function is used to read the previous record from a 
  2420.  
  2421.         data file. The data file is specified by df and user_data 
  2422.  
  2423.         points to the destination buffer for the record.
  2424.  
  2425.  
  2426.  
  2427.                 This function must be preceeded by some function that 
  2428.  
  2429.                 establishes the Current Record for the data file. For 
  2430.  
  2431.         example db_read_last followed by db_read_prev until end 
  2432.  
  2433.         of file occurs. The value of Current Record is reset to 
  2434.  
  2435.         NONE by a db_add. 
  2436.  
  2437.  
  2438.  
  2439.         db_read_prev should not be used with db_delete. db_delete
  2440.  
  2441.         positions the current pointer so that a db_read_next will
  2442.  
  2443.         be correct. A db_read_prev loop with deletes will skip
  2444.  
  2445.         records.
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.         o Returns
  2454.  
  2455.  
  2456.  
  2457.                 The data record is read into the buffer pointed to by
  2458.  
  2459.                 user_data. If the file type is Variable, the length of
  2460.  
  2461.         the record read is placed in data_size. The read record 
  2462.  
  2463.         becomes the Current Record for this data file. The 
  2464.  
  2465.         completion status is returned in the global db_error. 
  2466.  
  2467.         A non-zero value indicates an error.
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.         +----------+         ---------------------------         +----------+
  2476.  
  2477.         | db_reorg |         -  Reorganize Free Space  -         | db_reorg |
  2478.  
  2479.         +----------+         ---------------------------         +----------+
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.         o Summary
  2488.  
  2489.  
  2490.  
  2491.                 #include <db.h>
  2492.  
  2493.  
  2494.  
  2495.                 void db_reorg(df)
  2496.  
  2497.                   DATA_FILE  df;
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.         o Description
  2506.  
  2507.  
  2508.  
  2509.         When a VAR file record is deleted, the record is marked
  2510.  
  2511.         as deleted but still remains in the file. This function
  2512.  
  2513.         is used to reclaim the space held by deleted records.
  2514.  
  2515.         It is only valid for VAR files.
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.         o Returns
  2524.  
  2525.  
  2526.  
  2527.                 The completion status is returned in the global db_error. 
  2528.  
  2529.                 A non-zero value indicates an error.
  2530.  
  2531.  
  2532.  
  2533.         +-----------+      -------------------------------      +-----------+
  2534.  
  2535.         | db_update |      -  Update the Current Record  -      | db_update |
  2536.  
  2537.         +-----------+      -------------------------------      +-----------+
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.         o Summary
  2546.  
  2547.  
  2548.  
  2549.                 #include <db.h>
  2550.  
  2551.  
  2552.  
  2553.                 void db_update(df, user_data)
  2554.  
  2555.                   DATA_FILE  df;
  2556.  
  2557.                   void     *user_data;
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.         o Description
  2566.  
  2567.  
  2568.  
  2569.                 This function is used to update the Current Record for the
  2570.  
  2571.                 data file specified by df. The contents of the data record
  2572.  
  2573.                 pointed to by user_data are written back to the data file.
  2574.  
  2575.  
  2576.  
  2577.                 This function must be preceeded by some function that 
  2578.  
  2579.                 establishes the Current Record for the data file.
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.         o Returns
  2588.  
  2589.  
  2590.  
  2591.                 The completion status is returned in the global db_error. 
  2592.  
  2593.                 A non-zero value indicates an error. The Current Record
  2594.  
  2595.                 for the data file is reset to NONE.
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.         +---------------+    ---------------------------    +---------------+
  2602.  
  2603.         | db_update_atr |    -  Update Attribute Data  -    | db_update_atr |
  2604.  
  2605.         +---------------+    ---------------------------    +---------------+
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.         o Summary
  2614.  
  2615.  
  2616.  
  2617.                 #include <db.h>
  2618.  
  2619.  
  2620.  
  2621.                 void db_update_atr(df, user_data)
  2622.  
  2623.                   DATA_FILE  df;                 
  2624.  
  2625.                   void     *user_data;
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.         o Description
  2634.  
  2635.  
  2636.  
  2637.                 This function is used to update the attribute record for a
  2638.  
  2639.                 data file. The data file is specified by df and user_data
  2640.  
  2641.                 points to the source buffer to be written to the attribute
  2642.  
  2643.                 area for the data file.
  2644.  
  2645.  
  2646.  
  2647.                 The attribute data is a single user record that may be 
  2648.  
  2649.         used to store some global data for the data file.
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.         o Returns
  2660.  
  2661.  
  2662.  
  2663.                 The completion status is returned in the global db_error.
  2664.  
  2665.                 A non-zero value indicates an error.
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.         +-------------+     ------------------------------     +-------------+
  2672.  
  2673.         | fname_dflts |     -  Merge File Name Defaults  -     | fname_dflts |
  2674.  
  2675.         +-------------+     ------------------------------     +-------------+
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.         o Summary
  2684.  
  2685.  
  2686.  
  2687.                 char *fname_dflts(fname, dflt)
  2688.  
  2689.                   char *fname, *dflt;
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.         o Description
  2698.  
  2699.  
  2700.  
  2701.                 This function merges a file name string with a
  2702.  
  2703.                 default file name. For example the following would
  2704.  
  2705.                 force a default extension of ".c" if no extension
  2706.  
  2707.                 was present.
  2708.  
  2709.  
  2710.  
  2711.                         x = fname_dflts(fname,".c");
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.         o Returns
  2720.  
  2721.  
  2722.  
  2723.                 A pointer to the resulting static string is returned.
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.         +--------+           -----------------------              +--------+
  2730.  
  2731.         | fparse |           -  Parse a File Spec  -              | fparse |
  2732.  
  2733.         +--------+           -----------------------              +--------+
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.         o Summary
  2742.  
  2743.  
  2744.  
  2745.                 fparse(fstr, o_node, o_dev, o_dir, o_file, o_ext, o_ver)
  2746.  
  2747.                   char *fstr, *o_node, *o_dev, *o_dir, *o_file, *o_ext, *o_ver;
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.         o Description
  2756.  
  2757.  
  2758.  
  2759.                 This function parses a file specification fstr into component
  2760.  
  2761.                 parts. Not all of these components apply to generic MS-DOS.
  2762.  
  2763.  
  2764.  
  2765.                         o_node  - Node name
  2766.  
  2767.                         o_dev   - Device name
  2768.  
  2769.                         o_dir   - Directory Path
  2770.  
  2771.                         o_file  - File name
  2772.  
  2773.                         o_ext   - File extension
  2774.  
  2775.                         o_ver   - Version number
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.  
  2783.         o Returns
  2784.  
  2785.  
  2786.  
  2787.                 The component strings are copied into the buffers pointed
  2788.  
  2789.                 to by the o_* args.
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.         +------+              --------------------------             +------+
  2796.  
  2797.         | sort |              -  Callable Record Sort  -             | sort |
  2798.  
  2799.         +------+              --------------------------             +------+
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.         o Summary
  2808.  
  2809.  
  2810.  
  2811.                 void  sort_init(rec_size, spec_str)
  2812.  
  2813.                   int   rec_size;
  2814.  
  2815.                   char *spec_str;
  2816.  
  2817.  
  2818.  
  2819.                 void  sort_release(data_rec)
  2820.  
  2821.                   char *data_rec;
  2822.  
  2823.  
  2824.  
  2825.                 void  sort_merge()
  2826.  
  2827.  
  2828.  
  2829.                 char *sort_return(data_rec)
  2830.  
  2831.                   char *data_rec;
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.         o Description
  2840.  
  2841.  
  2842.  
  2843.                 This set of functions provides a callable record sort
  2844.  
  2845.                 facility:
  2846.  
  2847.  
  2848.  
  2849.                 sort_init - Initialize the sort. This must be done first.
  2850.  
  2851.                             rec_size = the size of the data record
  2852.  
  2853.                             spec_str = string of sort specs separated
  2854.  
  2855.                                        by commas. "spec,spec,spec..."
  2856.  
  2857.                             spec     = XXn.n
  2858.  
  2859.                                        ||| |
  2860.  
  2861.                                        ||| +--- size of field     (bytes)
  2862.  
  2863.                                        ||+----- starting position (1 relative)
  2864.  
  2865.                                        ||
  2866.  
  2867.                                        |+------ Format   A = Alpha
  2868.  
  2869.                                        |                 U = Unsigned integer
  2870.  
  2871.                                        |                 I = Integer
  2872.  
  2873.                                        |                 R = Real
  2874.  
  2875.                                        |
  2876.  
  2877.                                        +------- Sequence A = Ascending
  2878.  
  2879.                                                          D = Descending
  2880.  
  2881.  
  2882.  
  2883.                 sort_release - Release a record to the sort. data_rec
  2884.  
  2885.                                points to the data.
  2886.  
  2887.  
  2888.  
  2889.                 sort_merge   - Do the sort merge operation.
  2890.  
  2891.  
  2892.  
  2893.                 sort_return  - Return a record from the sort and put
  2894.  
  2895.                                it in data_rec. A pointer to the data
  2896.  
  2897.                                record is returned. A NULL value indicates
  2898.  
  2899.                                end of file.
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.         o Returns
  2908.  
  2909.  
  2910.  
  2911.                 If a sort error occurs an error message is printed and
  2912.  
  2913.                 the program aborts.
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.          ----------------end-of-author's-documentation---------------
  2920.  
  2921.                          Software Library Information:
  2922.  
  2923.                     This disk copy provided as a service of
  2924.  
  2925.                            Public (software) Library
  2926.  
  2927.          We are not the authors of this program, nor are we associated
  2928.          with the author in any way other than as a distributor of the
  2929.          program in accordance with the author's terms of distribution.
  2930.  
  2931.          Please direct shareware payments and specific questions about
  2932.          this program to the author of the program, whose name appears
  2933.          elsewhere in  this documentation. If you have trouble getting
  2934.          in touch with the author,  we will do whatever we can to help
  2935.          you with your questions. All programs have been tested and do
  2936.          run.  To report problems,  please use the form that is in the
  2937.          file PROBLEM.DOC on many of our disks or in other written for-
  2938.          mat with screen printouts, if possible.  PsL cannot debug pro-
  2939.          programs over the telephone, though we can answer questions.
  2940.  
  2941.          Disks in the PsL are updated  monthly,  so if you did not get
  2942.          this disk directly from the PsL, you should be aware that the
  2943.          files in this set may no longer be the current versions. Also,
  2944.          if you got this disk from another vendor and are having prob-
  2945.          lems,  be aware that  some files may have become corrupted or
  2946.          lost by that vendor. Get a current, working disk from PsL.
  2947.  
  2948.          For a copy of the latest monthly software library newsletter
  2949.          and a list of the 3,000+ disks in the library, call or write
  2950.  
  2951.                            Public (software) Library
  2952.                                P.O.Box 35705 - F
  2953.                             Houston, TX 77235-5705
  2954.  
  2955.                                 1-800-2424-PSL
  2956.                              MC/Visa/AmEx/Discover
  2957.  
  2958.                           Outside of U.S. or in Texas
  2959.                           or for general information,
  2960.                               Call 1-713-524-6394
  2961.  
  2962.                           PsL also has an outstanding
  2963.                           catalog for the Macintosh.
  2964.  
  2965.